package com.chensheng.service;

import com.chensheng.dao.ProductCategoryDAO;
import com.chensheng.model.ProductCategory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:ChenSheng
 * @Description:
 * @Date: Created in 上午 8:08 2018/5/14 0014
 */
@Service
@Slf4j
public class ProductCategorySercvice {

    @Autowired
    private ProductCategoryDAO productCategoryDAO;


    public List<ProductCategory> findAll(){
        List<ProductCategory> productCategoryList = productCategoryDAO.findAll();
        return productCategoryList;
    }

    public List<ProductCategory> findAll(Integer start, Integer offset){
        List<ProductCategory> productCategoryList = productCategoryDAO.findAllByPage(start, offset);
        return productCategoryList;
    }

    public List<ProductCategory> findByTypeList(List<Integer> categoryTypeList){
        return productCategoryDAO.selectByTypeList(categoryTypeList);
    }

    public Integer count() {
        return productCategoryDAO.count();
    }

    public ProductCategory findOne(Integer categoryId){
        return productCategoryDAO.findOne(categoryId);
    }

    public void saveOne(ProductCategory productCategory) {
        productCategoryDAO.insertOne(productCategory);
    }

    public void updateOne(ProductCategory productCategory) {
        productCategoryDAO.updateOne(productCategory);
    }
}
